package com.cloud.configclient;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@EnableEurekaClient
@EnableDiscoveryClient
@RestController
@RefreshScope
public class ConfigClientApplication implements CommandLineRunner {

    public static void main(String[] args) {
        SpringApplication.run(ConfigClientApplication.class, args);
    }


    @Value("${myname}")
    public String myname;

    @Value("${phone}")
    public String phone;

    @RequestMapping("/showConfig.do")
    public String showConfig(){
        return "myname:"+myname+"<p> phone："+phone;
    }


    @Override
    public void run(String... args) throws Exception {
        System.out.println("pull config results :\n myname :"+myname +", phone:"+phone);
    }
}
